﻿using System;
using System.Drawing;
using System.Globalization;
using System.Windows.Data;
using Brushes = System.Windows.Media.Brushes;

namespace T68Control.Procdure
{
    public class TestResultConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool? result = value as bool?;
            if (parameter.ToString() == "color3")
            {
                if (result == true)
                {
                    return Brushes.Green;
                }
                else if (result == false)
                {
                    return Brushes.OrangeRed;
                }
                else
                {
                    return ColorTranslator.FromHtml("#657274");
                }
            }
            else if (parameter.ToString() == "color2")
            {
                if (result == true)
                {
                    return Brushes.Green;
                }
                else if (result == false)
                {
                    return Brushes.OrangeRed;
                }
                else
                {
                    return Brushes.White;
                }
            }
            else if (parameter.ToString() == "color")
            {
                if (result == true)
                {
                    return Brushes.Green;
                }
                else if (result == false)
                {
                    return Brushes.OrangeRed;
                }
                else
                {
                    return Brushes.Transparent;
                }
            }
            else
            {
                if (result == true)
                {
                    return "PASS";
                }
                else if (result == false)
                {
                    return "FAIL";
                }
                else
                {
                    return "WAITING";
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}